DEFINITION FOR C MODULE Timer ;

FROM SYSTEM IMPORT ADDRESS ;
IMPORT Exec ;

CONST
  TIMERNAME = "timer.device" ;

(* unit defintions *)

  UNIT_MICROHZ	  = 0 ;
  UNIT_VBLANK	  = 1 ;
  UNIT_ECLOCK	  = 2 ;
  UNIT_WAITUNTIL  = 3 ;
  UNIT_WAITECLOCK = 4 ;

TYPE
  TimeValPtr     = POINTER TO TimeVal ;
  EClockValPtr   = POINTER TO EClockVal ;
  TimeRequestPtr = POINTER TO TimeRequest ;

  TimeVal = RECORD
    tv_secs  : LONGINT ;
    tv_micro : LONGINT ;
  END ;

  EClockVal = RECORD
    ev_hi : LONGINT ;
    ev_lo : LONGINT ;
  END ;

  TimeRequest = RECORD
    tr_node : Exec.IORequest ;
    tr_time : TimeVal ;
  END ;

(* IO_COMMAND to use for adding a timer *)
CONST
  TR_ADDREQUEST = Exec.CMD_NONSTD ;
  TR_GETSYSTIME	= Exec.CMD_NONSTD+1 ;
  TR_SETSYSTIME	= Exec.CMD_NONSTD+2 ;

VAR
  TimerBase : ADDRESS ;
(* Dice's auto-init code will setup TimerBase for you if you call any *)
(*  of the functions below.					      *)

PROCEDURE AddTime( dest , src : TimeValPtr ) ;
PROCEDURE SubTime( dest , src : TimeValPtr ) ;
PROCEDURE CmpTime( dest , src : TimeValPtr ) : LONGINT ;
PROCEDURE ReadEClock( VAR dest : EClockVal ) : LONGINT ;
PROCEDURE GetSysTime( VAR dest : TimeVal ) ;

END Timer.
